#include "stdheader.h"

/////////////////////////////////////////////////////////

COx::COx()
: CCharacter(CharacterType::Ox)
{
	m_tUpDownTex.loadFromFile("Resources/Art/Characters/OxDownUp.png");
	m_tUpDown.setTexture(m_tUpDownTex);

	m_tLeftRightTex.loadFromFile("Resources/Art/Characters/OxLeftRight.png");
	m_tLeftRight.setTexture(m_tLeftRightTex);
	
	// Oh dirty hacks. // Oh Hacks, you NAAAASTY.
	while (m_tSprite.getGlobalBounds().height > SC_HEIGHT * 0.085f)
	{
		m_tSprite.setScale(m_tSprite.getScale() * 0.99f);
	}

	m_tAnimation[0] = new CAnimation();
	m_tAnimation[0]->SetupAnimation(m_tUpDown, 2, 5, 0.075f);

	m_tAnimation[1] = new CAnimation();
	m_tAnimation[1]->SetupAnimation(m_tLeftRight, 2, 5, 0.075f);

	m_eAnimSprite = EAnimSprite_LeftRight;
}

COx::~COx()
{
}

/////////////////////////////////////////////////////////

void COx::DoMoveUp(float dt)
{
	m_tAnimation[0]->SetIdle(false);
	m_eAnimSprite = EAnimSprite_UpDown;
	m_tAnimation[0]->SetRow(0);
	m_vPosition.y -= GetMovementSpeed() * dt;
}

void COx::DoMoveDown(float dt)
{
	m_tAnimation[0]->SetIdle(false);
	m_eAnimSprite = EAnimSprite_UpDown;
	m_tAnimation[0]->SetRow(1);
	m_vPosition.y += GetMovementSpeed() * dt;
}

void COx::DoMoveLeft(float dt)
{
	m_tAnimation[1]->SetIdle(false);
	m_tAnimation[1]->SetRow(1);
	m_eAnimSprite = EAnimSprite_LeftRight;
	m_vPosition.x -= GetMovementSpeed() * dt;
}

void COx::DoMoveRight(float dt)
{
	m_tAnimation[1]->SetIdle(false);
	m_tAnimation[1]->SetRow(0);
	m_eAnimSprite = EAnimSprite_LeftRight;
	m_vPosition.x += GetMovementSpeed() * dt;
}

void COx::DoUseSkill()
{
}

void COx::DoUpdate(float dt)
{
	m_tAnimation[0]->Process(dt);
	m_tAnimation[1]->Process(dt);
}

/////////////////////////////////////////////////////////

void COx::DoRender(sf::RenderWindow* pWin)
{
	m_tAnimation[0]->SetPosition(m_vPosition);
	m_tAnimation[1]->SetPosition(m_vPosition);

	if (m_eAnimSprite == EAnimSprite_LeftRight)
		m_tAnimation[1]->Render(pWin);
	else
		m_tAnimation[0]->Render(pWin);
}

/////////////////////////////////////////////////////////

void COx::Idle()
{
	m_tAnimation[0]->SetIdle(true);
	m_tAnimation[1]->SetIdle(true);
}